package com.example.mapper;

import com.example.entity.Major;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MajorMapper {
    
    List<Major> selectAll(Major major);

    @Insert("insert into major (major_name, college_id) values (#{majorName},#{collegeId})")
    void insert(Major major);

    @Update("update major set major_name=#{majorName},college_id=#{collegeId} where major_id=#{majorId}")
    void update(Major major);

    @Delete("delete from major where major_id=#{majorId}")
    void delete(Integer majorId);

    @Select("select count(*) from major where  college_id=#{collegeId}")
    int countByCollegeId(Integer collegeId);

    @Select("select count(*) from major where major_name=#{majorName}")
    int countByMajorName(String majorName);

    @Select("select * from major where major_id=#{majorId}")
    Major selectById(Integer majorId);
}
